home *** CD-ROM | disk | FTP | other *** search
- /* -----------------------------------------------------------------------------
- ESDemo.h
-
- ©1995-2000 Ammon Skidmore, Skidperfect Software Inc. http://www.skidperfect.com/
- ----------------------------------------------------------------------------- */
-
- #ifndef __ESDemo__
- #define __ESDemo__
-
-
- #define toolOrOSTrap(trap) (trap & 0x0800) ? ToolTrap : OSTrap
- enum {
- uppPopupMenuSelectProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(long)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(MenuHandle)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(short)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
- };
- typedef UniversalProcPtr PopupMenuSelectUPP;
- #define NewPopupMenuSelectProc(proc) (PopupMenuSelectUPP) \
- NewRoutineDescriptor((ProcPtr)(proc), uppPopupMenuSelectProcInfo, GetCurrentISA())
-
- #define CallPopupMenuSelectProc(proc, p1, p2, p3, p4) \
- (long) CallUniversalProc((UniversalProcPtr)(proc), \
- uppPopupMenuSelectProcInfo, p1, p2, p3, p4)
-
- typedef UniversalProcPtr ButtonUPP;
- enum {
- uppButtonProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
- };
- #define NewButtonProc(proc) (ButtonUPP) \
- NewRoutineDescriptor((ProcPtr)(proc), uppButtonProcInfo, GetCurrentISA())
- #define CallButtonProc(proc) \
- (Boolean) CallUniversalProc((UniversalProcPtr)(proc), \
- uppButtonProcInfo)
-
- typedef UniversalProcPtr DrawPictureUPP;
- enum {
- uppDrawPictureProcInfo = kPascalStackBased
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(PicHandle)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Rect *)))
- };
- #define NewDrawPictureProc(proc) (DrawPictureUPP) \
- NewRoutineDescriptor((ProcPtr)(proc), uppDrawPictureProcInfo, GetCurrentISA())
- #define CallDrawPictureProc(proc, p1, p2) \
- CallUniversalProc((UniversalProcPtr)(proc), \
- uppDrawPictureProcInfo, p1, p2)
-
- PopupMenuSelectUPP gOldPopupMenuSelect, gPopupPatch=0L;
- ButtonUPP gSaveButton, gButtonPatch=0L;
- DrawPictureUPP gSaveDrawPicture, gDrawPicturePatch=0L;
- PicHandle gDownArrow;
- Handle gOldMDEF;
-
-
- #ifndef FALSE
- #define FALSE false
- #endif
- #ifndef TRUE
- #define TRUE true
- #endif
-
- // NB: normally, control strip module resources have ids >= 256
- #define rIconSuiteId (257)
- #define rPopupMenuID (256)
- #define rHierMenuID (255) // (ammon 000730) hierarchial menus must have id <= 255
- #define rArrowPictID (256)
- #define rMyStringsID (256)
- #define kTriangleWidth (9) // == width((*(**globH).myArrowPict)->picFrame);
- #define kSmallIconWidth (16)
- #define kLargeIconWidth (32)
-
- enum
- {
- kHelpStringIndex = 1
- };
-
- enum
- {
- kBeepIfPPC = 1,
- kBeepOnSubmenu,
- kMenuSep______________1,
- kHiliteClicks,
- kCustomBalloons,
- kCheckKeyDowns,
- kUseLargeIcon,
- kMenuSep______________2,
- kUseDragNDrop,
- kDragFiles,
- kDragTextClippings,
- kMenuSep______________3,
- kSafeFinderQuit1,
- kSafeFinderQuit2,
- kMenuSep______________4,
- kCloseDown
- };
-
- #define kFinderType 'FNDR'
- #define kSysCreator 'MACS'
-
- // useful macros:
- #define width(rect) ((rect).right - (rect).left) // macro for rect width
- #define height(rect) ((rect).bottom - (rect).top) // macro for rect height
- #define PicFrame(what) ((**MyGlobals.what).picFrame) // macro for picture frame rect
- #define pstrcpy(dst, src) (BlockMove((src), (dst), (src)[0] + 1))
-
- #ifdef DEBUG_ON
- #define DebugErr(num)\
- if (num)\
- {\
- Str255 s;\
- \
- NumToString(num, s);\
- DebugStr(s);\
- }
- #else
- #define DebugErr(num)
- #endif
-
- #ifdef DEBUG_ON
- #define DebugErrStr(str)\
- {\
- DebugStr(str);\
- }
- #else
- #define DebugErrStr(num)
- #endif
-
- // our structures:
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- typedef struct
- {
- Handle iconSuite;
- MenuRef myMenuH;
- MenuRef myHierMenuH; // (ammon 000730) added hierarchial menus example
- Handle myStrings;
- PicHandle myArrowPict;
- Boolean hasExtensionsStrip;
- Boolean useLargeIcon;
- long currentFeatures;
- // Drag globals:
- DragTrackingHandlerUPP myTrackingUPP;
- DragReceiveHandlerUPP myReceiveUPP;
- Boolean canAcceptDrag, hasEntered;
- Boolean acceptFiles, acceptText;
- ModuleReference myReferenceNum; // required only for Extensions Strip
- Rect myBox; // required only for Control/Desktop Strip
- } MyGlobals, *MyGlobalPtr, **MyGlobalHandle;
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- // our prototypes: //
- long sdevInit(WindowRef statusPort);
- void sdevClose(MyGlobalHandle myGlobals, WindowRef statusPort);
- long sdevClick(MyGlobalHandle myGlobals, const Rect *statusRect, WindowRef statusPort);
- void sdevDraw(MyGlobalHandle myGlobals, Rect *statusRect, GrafPtr statusPort);
- void DrawMyIcon(MyGlobalHandle myGlobals, Boolean selected);
- /* The gestalt code: */
- Boolean HasDragMgr(void);
- Boolean HasExtensionsStrip(void);
- /* The apple event code: */
- OSErr FindAProcess(OSType typeToFind, OSType creatorToFind,
- ProcessSerialNumberPtr processSN,
- ProcessInfoRecPtr infoRecToFill);
- void QuitProcess (ProcessSerialNumber PSN, Boolean hasExtensionsStrip);
- /* The drag manager code */
- void InstallDragHandlers(WindowRef statusPort, MyGlobalHandle myH);
- void RemoveDragHandlers(WindowRef statusPort, MyGlobalHandle myH);
- Boolean IsMouseInMyBounds(MyGlobalHandle globH, WindowRef win, DragReference theDrag);
- pascal OSErr DragTrackingHandler(short message, WindowRef theWindow,
- void *handlerRefCon, DragReference theDrag);
- pascal OSErr DragReceiveDropHandler(WindowRef theWindow, void *handlerRefCon,
- DragReference theDrag);
-
- #endif //__ESDemo__
-